package cn.enjoy.design.create.builder;

/**
 * @author K
 * @date 2020/11/6 10:37
 */
public class User {

    private String name;
    private String password;

    public User(String name, String password) {
        this.name = name;
        this.password = password;
    }

    public static class UserBuilder {
        private String name;
        private String password;

        public UserBuilder() {
        }

        ;

        public UserBuilder name(String name) {
            this.name = name;
            return this;
        }

        public UserBuilder password(String password) {
            this.password = password;
            return this;
        }

        public User build() {
            return new User(this.name, this.password);
        }

    }

    public static UserBuilder builder() {
        return new UserBuilder();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "User.UserBuilder(name=" + this.name + ", password=" + this.password + ")";
    }
}
